package com.kylin.common.util;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import com.kylin.common.Constants;

public class PropertyFileReader
{
 
 final String file = Constants.PROPERTIES;
 Properties property=null;
 static PropertyFileReader propertyFileReader=new PropertyFileReader();
 /**
  * 私有构造器
  */
 
 private PropertyFileReader()
 {
  super();
  
 }
 
 /**
  * 获取读取器实例
  * @return 读取器实例
  */
 public static PropertyFileReader getInstance()
 {
  
  return propertyFileReader;
 }
 /**
  * 加载属性文件
  * @param file 属性文件名
  * @return  c是否成功
  */
 public boolean LoadFile()
 {
  InputStream is = getClass().getResourceAsStream(file);	
  property = new Properties();
  try
  {
   property.load(is);
  }
  catch (FileNotFoundException e)
  {
   
   e.printStackTrace();
   return false;
  }
  catch (IOException e1)
  {
   e1.printStackTrace();
   return false;
  }
  
  return true;
 }
 /**
  * 读取属性值
  * @param propertyName 属性名
  * 
  */
 public String getPropertyValues(String propertyName)
 { 	  
      String propertyValues=property.getProperty(propertyName);
      return propertyValues;
 	
 }
 
}